import System.IO
import Control.Monad
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord

alphaScore :: String -> Int 
alphaScore xs = sum $ map ((subtract 64).ord) xs

main = do
	list <- readFile "names.txt"
	let euler_022 = sum $ map (\(x,y) -> y * (alphaScore x) ) $ zip (sort $ splitOn "," $ filter (/='\"') list) [1..]
	(putStrLn.show) euler_022